<template>
  <div class="app-container">

    <el-table
      v-loading="listLoading"
      :data="list"
      style="width: 100%"
      row-key="id"
      lazy
      border
      height="400"
      :load="load"
      :tree-props="{children: 'children' , hasChildren: 'hasChildren'}"
    >
      <el-table-column
        prop="name"
        label="菜单名称"
      />
      <el-table-column label="操作" width="80" align="center">
        <template slot-scope="{row}">
          <el-button ref="CREATE_BUTTON" type="primary" @click="setMenuData(row)">绑定</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import { GetSystemMenuList } from '@/api/SystemManagerApi'
export default {
  data() {
    return {
      listLoading: false,
      list: []
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      GetSystemMenuList().then(response => {
        this.list = response.data
        this.listLoading = false
      })
    },
    load(tree, treeNode, resolve) {
      GetSystemMenuList(tree.id).then(response => {
        const data = response.data
        resolve(data)
      })
    },
    setMenuData(row) {
      this.$emit('selectMenuData', row)
    }
  }
}
</script>
